package com.bacon.gmall.activity.service.impl;

import com.bacon.gmall.activity.service.SeckillService;
import com.bacon.gmall.common.constant.RedisConst;
import com.bacon.gmall.model.activity.SeckillGoods;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author： bacon、
 * @version： 1.0
 * @create： 2021-01-13 16:52
 * @description:
 */
@Service
public class SeckillServiceImpl implements SeckillService {

    @Autowired
    private RedisTemplate redisTemplate;

    @Override
    public List<SeckillGoods> list() {
        return redisTemplate.opsForHash().values(RedisConst.SECKILL_GOODS);
    }

    @Override
    public SeckillGoods getSeckillGoods(Long skuId) {


        return (SeckillGoods) redisTemplate.opsForHash().get(
                RedisConst.SECKILL_GOODS,
                skuId.toString());
    }
}
